﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media.Imaging;
using ClimateControl.Infrastructure;

namespace ClimateControl.Controls.Converters
{
    public class StateToVotingEnabledConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            bool isReady = false;

            if (value is State)
            {
                switch ((State)value)
                {
                    case State.Connecting:
                    case State.Waiting:
                    case State.SendingVote:
                    case State.VoteSent:
                    case State.Upgrading:
                        isReady = false;
                        break;
                    case Infrastructure.State.Ready:
                        isReady = true;
                        break;
                }
            }

            return isReady;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
 	        throw new NotImplementedException();
        }
    }
}
